
const tokens = {
  admin: {
    token: 'admin-token'
  },
  'admin@163.com': {
    token: 'admin-token'
  }
}

const users = {
  'admin-token': {
    // roles: ['admin'],
    uid: 13,
    role: '管理员',
    id_role: 1,
    depart: '运营一部',
    name: '张三',
    account: 'admin@163.com'
  }
}

var data = [
  // 用户登录
  {
    url: '/user/login',
    type: 'post',
    response: config => {
      const { username, password } = config.body
      console.log('mock login', username, password)
      const token = tokens[username]

      // mock error
      if (!token) {
        return {
          code: 60204,
          msg: 'Account and password are incorrect.'
        }
      }

      return {
        code: 1,
        data: token
      }
    }
  },
  // 取得会员信息
  {
    url: '/user/info.*',
    type: 'get',
    response: config => {
      // console.log('user/info', config)
      const { token } = config.query
      const info = users[token]

      // mock error
      if (!info) {
        return {
          code: 201,
          msg: 'Login failed, unable to get user details.'
        }
      }

      return {
        code: 1,
        data: info
      }
    }
  },
  // 用户其它配置信息
  {
    url: '/user/roles',
    type: 'get',
    response: () => {
      return {
        code: 1,
        data: [
          {
            id: 1,
            name: '普通员工'
          },
          {
            id: 2,
            name: '负责人'
          },
          {
            id: 3,
            name: '管理员'
          }
        ]
      }
    }
  },
  {
    url: '/depart/list',
    type: 'get',
    response: () => {
      return {
        code: 1,
        data: [
          {
            id: 1,
            name: '技术部',
            admin: '张三',
            id_admin: 1,
            is_update: 1,
            is_delete: 0,
          },
          {
            id: 2,
            name: '产品部',
            admin: '李四',
            id_admin: 2,
            is_update: 1,
            is_delete: 1,
          },
          {
            id: 3,
            name: '美术部',
            id_admin: 3,
            admin: 'ss'
          }
        ]
      }
    }
  },
  // 团队-> 人员管理列表
  {
    url: '/user/list',
    type: 'get',
    response: () => {
      return {
        code: 1,
        total: 100,
        data: [{
          id: 1,
          name: '张三',
          account: 'test001@163.com',
          depart: '技术部',
          id_depart: 2,
          role: '负责人',
          id_role: 2,
          status: '1',
          is_update: 1,
          is_delete: 1,
        }, {
          id: 2,
          name: '李四',
          account: 'test002@163.com',
          depart: '运营部',
          id_depart: 1,
          role: '普通员工',
          id_role: 1,
          status: '-1',
          is_update: 1,
          is_delete: 0,
        },
        {
          id: 3,
          name: '王五',
          account: 'test003@163.com',
          depart: '行政部',
          id_depart: 3,
          role: '管理员',
          id_role: 3,
          status: 1
        },
        {
          id: 4,
          name: '马六',
          account: 'test003@163.com',
          depart: '行政部',
          id_depart: 3,
          role: '管理员',
          id_role: 3,
          status: 1
        }
        ]
      }
    }
  },
  {
    url: '/user/add',
    type: 'post',
    response: () => {
      // 添加人员
      return {
        code: 1,
        msg: 'success'
      }
    }
  },
  ///user/del
  {
    url: '/user/del',
    type: 'get',
    response: () => {
      // 删除人员
      return {
        code: 1,
        msg: 'success'
      }
    }
  },
  // user logout
  {
    url: '/user/logout',
    type: 'post',
    response: () => {
      return {
        code: 1,
        msg: 'success'
      }
    }
  },
  {
    // 项目目标相关
    url: '/user/project/list',
    type: 'get',
    response: () => {
      return {
        code: 1,
        total: 200,
        data: [
          {
            id: 1,
            user: '张三',
            name: '抖音项目',
            target: '1400000',
            target_own: '80000',
            finish: '80%'
          }, {
            id: 2,
            user: '李四',
            name: '抖音项目',
            target: '1400000',
            target_own: '82000',
            finish: '80%'
          }
        ]
      }
    }
  },
  {
    url: '/project/user/save',
    type: 'post',
    response: () => {
      return {
        code: 1,
        msg: 'success'
      }
    }
  },
  {
    // 用户消息列表
    url: '/user/message',
    type: 'get',
    response: () => {
      return {
        code: 1,
        data: [
          {
            id: 1,
            name: '技术部通知',
            date: '07/22',
            status: 0,
          },
          {
            id: 2,
            name: '产品部通知',
            date: '07/22',
            status: 0,
          },
          {
            id: 3,
            name: '美术部通知',
            date: '07/22',
            status: 0,
          }
        ]
      }
    }
  },
  {
    url: '/user/message/read',
    type: 'get',
    response: () => {
      return {
        code: 1,
        msg: 'success'
      }
    }
  },
  {
    url: '/depart/del',
    type: 'get',
    response: () => {
      // 删除人员
      return {
        code: 1,
        msg: 'success'
      }
    }
  },
  {
    url: '/user/password',
    type: 'post',
    response: () => {
      // 删除人员
      return {
        code: 1,
        msg: 'success'
      }
    }
  },
  {
    url: '/user/status',
    type: 'post',
    response: () => {
      // 停用人员
      return {
        code: 1,
        data: {
          new_status: 0,
        }
      }
    }
  },
]

module.exports = data